const name = 'product-create-darg-demo'

export const saveItem = (key, value) => {
  let storage = window.localStorage.getItem(name)
  if (!storage) {
    storage = {}
  } else {
    storage = JSON.parse(storage)
    storage[key] = value
  }
  window.localStorage.setItem(name, JSON.stringify(storage))
}

export const loadItem = (key, def) => {
  const storage = window.localStorage.getItem(name)
  if (!storage) {
    return def
  } else {
    return JSON.parse(storage)[key] || def
  }
}
